# 导包
import requests
import config


# 创建接口类
class OrderAPI:
    # 初始化
    def __init__(self):
        self.url_order_list = config.BASE_URL + "/api/v1/order/by_user?page=1"
        self.url_add_order = config.BASE_URL + "/api/v1/order"
        self.url_order = config.BASE_URL + "/api/v1/order/{}"
    # 获取订单列表
    def get_order_list(self):
        return requests.get(url=self.url_order_list, headers={"token": config.TOKEN})
    # 创建订单
    def add_order(self, add_data):
        return requests.post(url=self.url_add_order, json=add_data, headers={"token": config.TOKEN})

    # 查看订单
    def get_order_info(self, order_id):
        return requests.get(url=self.url_order.format(order_id), headers={"token": config.TOKEN})


